package com.aograph.listeners;

import com.aograph.entity.AirlinePredict;
import org.kie.api.event.rule.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * ┏┓　　　┏┓
 * ┏┛┻━━━┛┻┓
 * ┃　　　　　　　┃
 * ┃　　　━　　　┃
 * ┃　┳┛　┗┳　┃
 * ┃　　　　　　　┃
 * ┃　　　┻　　　┃
 * ┃　　　　　　　┃
 * ┗━┓　　　┏━┛
 * 　　┃　　　┃神兽保佑
 * 　　┃　　　┃代码无BUG！
 * 　　┃　　　┗━━━┓
 * 　　┃　　　　　　　┣┓
 * 　　┃　　　　　　　┏┛
 * 　　┗┓┓┏━┳┓┏┛
 * 　　　┃┫┫　┃┫┫
 * 　　　┗┻┛　┗┻┛
 *
 * @author lelezhang
 * @description
 * @create 2022/3/30
 **/
public class AographRuleRuntimeEventListener extends DefaultRuleRuntimeEventListener {
    private static Logger logger= LoggerFactory.getLogger(AographAgendaEventListener.class);

    @Override
    public void objectInserted(ObjectInsertedEvent event) {
        Object obj =event.getObject();
        if (obj instanceof AirlinePredict){
            AirlinePredict airlinePredict =(AirlinePredict) obj;
            StringBuffer sb = new StringBuffer("skey=" +airlinePredict.getSkey());
            sb.append(",model_type=" + airlinePredict.getModel_type());
            sb.append(",rule_predict_price=" + airlinePredict.getRule_predict_price());
            sb.append(",label=" + airlinePredict.getLabel());
            sb.append(",std_price=" + airlinePredict.getStd_price());
            sb.append(",ota_kzl=" + airlinePredict.getOta_kzl());
            sb.append(",ex_dif=" + airlinePredict.getEx_dif());
            sb.append(",compete_lowest_price=" + airlinePredict.getCompete_lowest_price());
            sb.append(",jf_aircode_class=" + airlinePredict.getJf_aircode_class());
            sb.append(",compete_fltno=" + airlinePredict.getCompete_fltno());
            sb.append(",price_gap=" + airlinePredict.getPrice_gap());

            logger.info(sb.toString());
        }
    }

    @Override
    public void objectUpdated(ObjectUpdatedEvent event) {
        Object obj =event.getObject();
        if (obj instanceof AirlinePredict){
            AirlinePredict airlinePredict =(AirlinePredict) obj;
            StringBuffer sb = new StringBuffer("skey=" +airlinePredict.getSkey());
            sb.append(",model_type=" + airlinePredict.getModel_type());
            sb.append(",rule_predict_price=" + airlinePredict.getRule_predict_price());
            sb.append(",label=" + airlinePredict.getLabel());
            sb.append(",std_price=" + airlinePredict.getStd_price());
            sb.append(",ota_kzl=" + airlinePredict.getOta_kzl());
            sb.append(",ex_dif=" + airlinePredict.getEx_dif());
            sb.append(",compete_lowest_price=" + airlinePredict.getCompete_lowest_price());
            sb.append(",jf_aircode_class=" + airlinePredict.getJf_aircode_class());
            sb.append(",compete_fltno=" + airlinePredict.getCompete_fltno());
            sb.append(",price_gap=" + airlinePredict.getPrice_gap());

            logger.info(sb.toString());
        }
    }

    @Override
    public void objectDeleted(ObjectDeletedEvent event) {

    }
}
